from tortoise import fields
from datetime import datetime
from .base import BaseModel, TimestampMixin


class SysRole(BaseModel, TimestampMixin):
    """角色信息表"""

    role_id = fields.IntField(pk=True, description="角色ID")

    role_name = fields.CharField(max_length=30, description="角色名称")

    role_key = fields.CharField(max_length=100, description="角色权限字符串")

    role_sort = fields.IntField(description="显示顺序")

    data_scope = fields.CharField(max_length=1, null=True, description="数据范围（1：全部数据权限 2：自定数据权限 3：本部门数据权限 4：本部门及以下数据权限）")

    menu_check_strictly = fields.IntField(null=True, description="菜单树选择项是否关联显示")

    dept_check_strictly = fields.IntField(null=True, description="部门树选择项是否关联显示")

    status = fields.CharField(max_length=1, description="状态（0正常 2删除）")

    use_flag = fields.CharField(max_length=1, null=True, description="角色状态（0正常 1停用）")

    create_by = fields.CharField(max_length=64, null=True, description="创建者")

    create_time = fields.DatetimeField(null=True, description="创建时间")

    update_by = fields.CharField(max_length=64, null=True, description="更新者")

    update_time = fields.DatetimeField(null=True, description="更新时间")

    remark = fields.CharField(max_length=500, null=True, description="备注")

    class Meta:
        table = "sys_role"

    def __str__(self):
        return f"{self.role_id}"